from selenium.webdriver.common.by import By

from base.page_base import PageBase


class OrderPage(PageBase):
    """订单页面"""
    # 定位元素
    #进入首页点击购物车
    __cart = (By.XPATH,'(//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/img_mainpage_tab_icon"])[3]')
    #点击结算
    __settlement = (By.XPATH,'//android.widget.TextView[@text="结算(1)"]')
    #点击提交订单按钮
    __submit = (By.XPATH,'//android.widget.TextView[@resource-id="com.netease.yanxuan:id/order_btn"]')
    __mine = (By.XPATH, '//*[@text="个人"]')
    __waitpayment = (By.XPATH, '(//android.widget.ImageView[@resource-id="com.netease.yanxuan:id/order_icon"])[2]')
    __order_text = (By.ID, "com.netease.yanxuan:id/tv_commodity_name")
    def click_cart(self):
        """点击购物车"""
        self.base_click(self.__cart)
    def click_settlement(self):
        """点击结算"""
        self.base_click(self.__settlement)
    def click_submit(self):
        """点击提交订单"""
        self.base_click(self.__submit)
    def click_mine(self):
        """点击个人"""
        self.base_click(self.__mine)
    def click_waitpayment(self):
        """点击待付款"""
        self.base_click(self.__waitpayment)
    def get_order_text(self):
        """获取订单名称"""
        return self.base_get_text(self.__order_text)
    def assertion(self):
        """提交订单"""
        self.click_mine()
        self.click_waitpayment()


